﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Utilities.Helper
{
    public static class UtilityHelper
    {
        /// <summary>
        /// Parser string value to ENum value
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="value"></param>
        /// <returns></returns>
        public static T ParseEnum<T>(string value)
        {
            return (T)Enum.Parse(typeof(T), value, true);
        }

        /// <summary>
        /// Get current application directory path
        /// </summary>
        public static string CurrentAppDirectoryPath
        {
            get
            {
                return Directory.GetCurrentDirectory();
            }
            set { }
        }
        //public static string SQLValueConversion(string Val, Declarations.DBDataType Type)
        //{
        //    try
        //    {
        //        if (Val == null || Val == string.Empty)
        //            Val = "NULL";
        //        else if (Type == Declarations.DBDataType.STRING)
        //        {
        //            Val = Val.Replace("'", "''");
        //            Val = "'" + Val + "'";
        //        }
        //        else if (Type == Declarations.DBDataType.BOOL)
        //        {
        //            if (Val.Trim().ToUpper() == "TRUE" || Val.Trim() == "1")
        //                Val = "1";
        //            else
        //                Val = "0";
        //        }
        //        else if (Type == Declarations.DBDataType.NUMERIC)
        //            Val = Val.Trim();
        //        else if (Type == Declarations.DBDataType.DATETIME)
        //        {
        //            DateTime dt = new DateTime();
        //            DateTime.TryParse(Val,out dt);
        //            Val = "'" + dt.ToString("yyyy-MM-dd HH:mm:ss")+"'";
        //        }

        //    }
        //    catch (Exception ex)
        //    {
        //        Logger.Log(ex.ToString());                
        //    }

        //    return Val;
        //}
    }
}
